﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php
using System.Collections.Generic;

namespace DNA.Mvc
{
    /// <summary>
    /// Defines the methods to mainpluate WidgetDescriptor data objects.
    /// </summary>
    public interface IWidgetDescriptorRepository : IRepository<WidgetDescriptor>
    {
        WidgetDescriptor Create(WidgetTemplate template, string installPath);

        WidgetDescriptor Update(WidgetTemplate template, WidgetDescriptor descriptor);

        /// <summary>
        /// Delete the specified descriptor by id.
        /// </summary>
        /// <param name="id">The specified descriptor id.</param>
        void Delete(int id);

        /// <summary>
        /// Delete the WidgetDescriptor by specified installedPath.
        /// </summary>
        /// <param name="installedPath"></param>
        void Delete(string installedPath);

        /// <summary>
        /// Gets the WidgetDescriptor by specified controller name and action name.
        /// </summary>
        /// <param name="controllerName">The controller that contains the widget definition.</param>
        /// <param name="action">The widget Action name.</param>
        /// <returns>The WidgetDescriptor instance.</returns>
        WidgetDescriptor Find(string controllerName, string action);

        /// <summary>
        /// Gets the WidgetDescriptor by specified installation path.
        /// </summary>
        /// <param name="installedPath"></param>
        /// <returns></returns>
        WidgetDescriptor Find(string installedPath);

        IEnumerable<WidgetDescriptor> WithInPath(string path);

        int InusingWidgetsCount(string installedPath);
    }
}
